package com.fly.common.msg;

import java.io.Serializable;

/**
 * @CLASSNAME: ResultMsg
 * @author: Fly
 * 日期: 2020/6/7  18:23
 * 描述: 返回对象
 **/
public class ResultMsg implements Serializable {


    public final static String SUCCESS_CODE = "0";
    public final static String SUCCESS_MSG = "操作成功";
    public final static String ERROR_CODE = "500";
    public final static String ERROR_MSG = "操作失败";



    private String msg;
    private String code;

    public ResultMsg() {
    }
    public ResultMsg(String msg, String code) {
        this.msg = msg;
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public static ResultMsg success(String msg,String code){
        return new ResultMsg(msg,code);
    }

    public static ResultMsg success(String code){
        return success(null,code);
    }

    public static ResultMsg success(){
        return success(SUCCESS_MSG,SUCCESS_CODE);
    }

    public static ResultMsg error(String msg){
        return new ResultMsg(msg,ERROR_CODE);
    }

    public static ResultMsg error(){
        return new ResultMsg(ERROR_MSG,ERROR_CODE);
    }
}
